package com.tf_cut.backend.request.xml;

import com.tf_cut.backend.request.MybankApiException;
import com.tf_cut.backend.request.MybankParser;
import com.tf_cut.backend.request.MybankResponse;

/**
 * XML对象解析器
 */
public class ObjectXmlParser<T extends MybankResponse> implements MybankParser<T> {

    private Class<T> clazz;

    public ObjectXmlParser(Class<T> clazz) { this.clazz = clazz; }

    @Override
    public T parse(String responseXml) throws MybankApiException {
        XmlConverter converter = XmlConverter.getInstance();
        return converter.toResponse(responseXml, clazz);
    }

    @Override
    public Class<T> getResponseClass() {
        return clazz;
    }
}